var network = {
	setStorage:function($key,$data,callback){
		uni.setStorage({
			key:$key,
			data:$data,
			success:function(){
				callback();
			}
		})
	},
	getStorage:function($key,callback,func){
		uni.getStorage({
			key:$key,
			success:function(e){
				callback(e.data)
			},
			fail:function(){
				func();
			}
		})
	},
	request:function($data,callback){
		uni.request({
			url:'https://yp.6vx.com/?m=Jke',
			data:$data,
			method:'POST',
			header:{
				"Content-Type": "application/x-www-form-urlencoded"
			},
			success:function(res){
				// console.log(res)
				if (res.data.rescode == 0) {
				  callback(res.data.data);
				} else {
				  if (res.data.rescode == 8002) {
					network.showModel(
						'您的账号存在异常，您已被封号~',
					)
						return false;
				  } else if (res.data.rescode == 8001) {
					  network.showModel('您的身份验证失败，请登录后重试~',
							function(){
									uni.reLaunch({
										url: '/pages/login/login?btn=true',
									})
							}
					  )
						return false;
				  } else {
						if(res.data.resdesc=='鲜花数量不足'){
							uni.showModal({
								content: res.data.resdesc,
								cancelText: '返回',
								confirmColor:'#6E6CFD',
								confirmText:'获取更多',
								success:function(res){
									if(res.confirm){
										uni.navigateTo({
											url:"/pagesA/getHua/getHua"
										})
									}
								}
							})
						}else{
							uni.showModal({
								content: res.data.resdesc,
								confirmColor:'#6E6CFD',
								cancelText: '返回',
								success:function(res){
									if(res.cancel){
										uni.navigateBack({
										
										})
									}
								}
							})
						}
						return false;
				  }
				}
			},
			fail:function(){
				
			}
		})
	},
	getHeight:function(callback){
		uni.getSystemInfo({
			success:function(res){
				var windowH = res.screenHeight || res.windowHeight;
				var windowW = res.screenWidth || res.windowWidth;
				var bar = res.statusBarHeight;
				callback(windowH,windowW,bar);
			}
		})
	},
	showModel:function(contText,func){
		uni.showModal({
			content:contText,
			showCancel:false,
			confirmColor:'#6E6CFD',
			success:function(res){
				if(res.confirm){
					func();
				}
			},
			
		})
	}
}
module.exports.network = network;